<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>最佳实践库统计</title>
    <!--公用样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/comment.css"/>
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/supplier/common/css/style.css"/>
    <!--extended-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/extended.css"/>
    <!--Layui-->
    <link rel="stylesheet" href="${re.contextPath}/plugin/layui/css/layui.css" media="all"/>

    <!--公用样式JS-->
    <script type="text/javascript" src="${re.contextPath}/plugin/jquery/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/comment.js"></script>
    <script type="text/javascript" src="${re.contextPath}/plugin/layui/layui.js" charset="utf-8"></script>
</head>
<style>
    .Right {
        overflow-y: auto;
        width: 100%;
        left: 16%;
        top: 144px;
    }

    .widthle {
        width: 35%;
        display: inline-block;
        text-align: right;
    }

    .widthle25 {
        width: 25%;
        display: inline-block;
        text-align: right;
    }

    .widinput {
        width: 60% !important;
    }

    xm-select {
        min-height: 30px;
        line-height: 30px;
    }

    .tab-name-unselect {
        font-weight: bolder;
        font-size: 18px !important;
        color: #888888;
    }

    .tab-name-select {
        font-weight: bolder;
        font-size: 18px !important;
        color: #1e9fff !important;
        background-color: #ffffff !important;
    }

    .layui-laypage-limits select {
        width: 70px;
    }

    .layui-table tbody tr:hover, .layui-table-hover, .layui-table-click {
        background-color: rgba(255, 255, 255, 0);
    }

    .layui-tab-brief > .layui-tab-more li.layui-this:after, .layui-tab-brief > .layui-tab-title .layui-this:after {
        border-bottom: 2px solid #1e9fff !important;
    }
</style>

<body>
<!--头部-->

<!--容器-->
<div class="layui-container"
     style="background-color: #ffffff;width:96%;margin-top:60px;padding:16px;border-radius: 10px">


    <!--tab页面-->
    <div class="layui-tab layui-tab-brief" lay-filter="demo">
        <ul id="tab-uls" class="layui-tab-title" style="margin: 0px 10px 10px 10px">
            <li class="layui-this tab-name-select" value="1">成果类型统计</li>
            <li class="tab-name-unselect" value="2">人员统计</li>
            <li class="tab-name-unselect" value="3">部门统计</li>
        </ul>

        <div class="layui-tab-content" style="height: auto;">

            <div class="layui-tab-item layui-show" style="margin-left: 0px">
                <!--筛选行-->
            </div>

            <div class="layui-tab-item" style="margin-left: 0px">
                <!--筛选行-->
                <from id="form-search">
                    <div style="background-color: #F1F4FB;border-radius: 5px;padding:14px 10px;">
                        <div class="layui-row">
                            <div class="layui-col-md6" style="padding-left:2%">
                                <span>姓名:</span>
                                <input id="createUsername" class="layui-input layui-input-inline" type="text"
                                       placeholder=""
                                       style="width: 50%">
                            </div>
                            <div class="layui-col-md1" style="text-align: end;width: 20%;float: right;">
                                <input class="layui-btn layui-btn-normal" style="border-radius:5px;" type="button"
                                       value="筛选"
                                       onclick="query(2)">
                                <input class="layui-btn layui-btn-normal ml10" type="button"
                                       style="border-radius:5px;background-color: #FF5722;" value="重置"
                                       onclick="resetQuery()">
                            </div>
                        </div>
                    </div>
                </from>
            </div>
            <div class="layui-tab-item" style="margin-left: 0px">
                <!--筛选行-->
                <#--                <div style="background-color: #F1F4FB;border-radius: 5px;padding:14px 10px;">-->
                <#--                    <div class="layui-row">-->
                <#--                        <div class="layui-col-md4" style="padding-left:1%">-->
                <#--                            <span>证书名称:</span>-->
                <#--                            <input id="certName" class="layui-input layui-input-inline" type="text" placeholder="证书"-->
                <#--                                   style="width: 50%">-->

                <#--                            createUsername-->
                <#--                        </div>-->
                <#--                        <div class="layui-col-md3">-->
                <#--                            &lt;#&ndash;				<input class="layui-btn layui-btn-danger layui-btn-sm fr ml10" type="button" value="重置" onclick="resetQuery()">&ndash;&gt;-->
                <#--                            <input class="layui-btn layui-btn-normal" type="button" value="筛选" onclick="query(3)">-->
                <#--                        </div>-->
                <#--                    </div>-->
                <#--                </div>-->
            </div>
        </div>
    </div>


</div>
<div class="layui-container"
     style="background-color: #ffffff;width:96%;margin-top:30px;padding:16px;border-radius: 10px">
    <#--    <div class="layui-row">
            <div class="layui-col-md3 layui-col-md-offset9">
                <input class="layui-btn layui-btn-normal layui-btn-sm fr ml10" type="button" value="导出Excel" onclick="exportTable()">
                <input class="layui-btn layui-btn-danger layui-btn-sm fr" type="button" value="预览Excel" onclick="viewTable()">
            </div>
        </div>-->
    <@shiro.hasPermission name="search:export">
        <input class="layui-btn layui-btn-normal layui-btn-sm fr ml10" type="button" value="导出Excel"
               onclick="exportTable()">
    </@shiro.hasPermission>
    <@shiro.hasPermission name="search:view">
        <input class="layui-btn layui-btn-danger layui-btn-sm fr" type="button" value="预览Excel" onclick="viewTable()">
    </@shiro.hasPermission>
    <div class="layui-row">
        <table id="tableList" class="layui-hide" lay-filter="tableList"></table>
    </div>
</div>
<script type="text/javascript" src="${re.contextPath}/plugin/tools/tool.js"></script>
<script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/tabs.js"></script>
<script type="text/javascript" src="${re.contextPath}/pageoffice.js" id="po_js_main"></script>
<!-- 公共配置第三方组件 -->
<script type="text/javascript">
    layui.config({
        version: false,
        debug: false,
        base: "${re.contextPath}/plugin/layui/lay/extra/"
    })

</script>
<script type="text/javascript">
    var defaultTabInd = 0;
    var indexnm = 0;
    var layer;
    var form = layui.form;
    var table = null;
    var _xstjlcpselect;
    var tableIns = null;
    //注意进度条依赖 element 模块，否则无法进行正常渲染和功能性操作
    var element = "";
    layui.use('element', function () {
        element = layui.element;
        getTableByIndex(0)
        element.on('tab(demo)', function (data) {
            if (defaultTabInd == data.index) {
            } else {
                defaultTabInd = data.index;
                $('#form-search').find('input[type=text],select,input[type=number]').each(function () {
                    $(this).val('');
                });
                $('#tab-uls li').addClass("tab-name-unselect");
                $('#tab-uls li').removeClass("tab-name-select");
                $('#tab-uls li:eq(' + data.index + ')').removeClass("tab-name-unselect");
                $('#tab-uls li:eq(' + data.index + ')').addClass("tab-name-select");
                getTableByIndex(data.index);
            }
        });


    });
    layui.use('laydate', function () {
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#beginDate' //指定元素
        });
        laydate.render({
            elem: '#endDate' //指定元素
        });
    });

    function query(obj) {
        var jsondata = {};
        if (obj == '2') {
            var createUsername = $('#createUsername').val();
            jsondata = {
                createUsername: createUsername
            };
        } else if (obj == '3') {
            var certName = $('#createUsername').val();
            jsondata = {
                certName: certName
            };
        } else if (obj == '1') {


        }

        table.reload('tableList', {where: jsondata});
    }

    function resetQuery() {

        $('#form-search').find('input[type=text],select,input[type=number]').each(function () {
            $(this).val('');
        });
        var jsondata = {
            createUsername: ''
        }
        table.reload('tableList', {where: jsondata});
    }


    function getTableByIndex(index) {
        //根据条件加载表格:
        if (index == 0) {
            //按照人员统计
            getTablePersonInfo();
        } else if (index == 1) {
            //按照擅长领域统计
            getTableDoBest();
        } else if (index == 2) {
            //按照证书统计
            getTableZf();
        }
    }

    function getTablePersonInfo() {
        layui.use('table', function () {
            table = layui.table;
            element = element;
            //方法级渲染
            tableIns = table.render({
                id: 'tableList',
                elem: '#tableList',
                url: '/search/decision/showcgList',
                height: "auto",
                page: false,
                cols: [[
                    {
                        field: "ordernum", title: '序号', width: '100', align: 'center'
                    },
                    {
                        field: 'fileName',
                        title: '成果类型',
                        align: 'left',
                        width: '700',
                        sort: false,
                        templet: function (d) {

                            if (d.scflag == '0') {
                                return "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + d.fileName;
                            } else {
                                return d.fileName;
                            }
                        }
                    },
                    {
                        field: 'scflag', align: 'center', width: '100', sort: true, hide: true
                    },
                    {
                        field: 'id', title: 'id', width: '100', sort: true, hide: true
                    },
                    {
                        field: 'num', title: '数量', align: 'center', width: '300', sort: false,
                        templet: function (d) {
                            return '<span class="cursor" style="color: blue;" onclick="wjdetail(\'' + d.id + '\',\'' + 'cg' + '\')">' + d.num + '</span>';
                        }
                    }
                ]],
                done: function (res, currentCount) {
                    //***重点***：table渲染完成后渲染element进度条
                    element.render();
                    $(".layui-table-page select").css("width", "80px");

                }
            });

        });


    }

    function wjdetail(id, types) {
        var type = "auto";
        var w = "70%";
        var h = "90%";
        url = "/search/decision/bastPracticeFile?id=" + id + "&cgType=" + types;
        layer.open({
            id: 'form-add',
            type: 2,
            area: [w, h],
            fix: false,
            maxmin: true,
            shadeClose: false,
            shade: 0.4,
            title: "文档列表",
            content: url,
            end: function () {

            }
        });

    }

    function getTableDoBest() {
        layui.use('table', function () {
            table = layui.table;
            element = element;
            //方法级渲染
            tableIns = table.render({
                id: 'tableList',
                elem: '#tableList',
                url: '/search/decision/showFileByUserZj',
                height: "auto",
                page: true,
                cols: [[
                    {
                        title: '序号', width: '10%', align: 'center', templet: function (res) {
                            return res.LAY_INDEX;
                        }
                    },
                    {
                        field: 'id', title: 'id', align: 'center', width: '15%', sort: true, hide: true
                    },
                    {
                        field: 'createUsername', title: '姓名', align: 'center', width: '15%', sort: true
                    },
                    {
                        field: 'num1',
                        title: '案例总结数',
                        align: 'center',
                        width: '15%',
                        sort: true,
                        templet: function (d) {
                            return '<span class="cursor" style="color: blue;" onclick="showDetailChange(\'' + d.id + '\',\'' + 103 + '\',\'' + d.createUsername + '\')">' + d.num1 + '</span>';
                        }
                    },
                    {
                        field: 'num2',
                        title: '行业总结数',
                        align: 'center',
                        width: '15%',
                        sort: true,
                        templet: function (d) {
                            return '<span class="cursor" style="color: blue;" onclick="showDetailChange(\'' + d.id + '\',\'' + 104 + '\',\'' + d.createUsername + '\')">' + d.num2 + '</span>';
                        }
                    },
                    {
                        field: 'num3',
                        title: '束后总结数',
                        align: 'center',
                        width: '15%',
                        sort: true,
                        templet: function (d) {
                            return '<span class="cursor" style="color: blue;" onclick="showDetailChange(\'' + d.id + '\',\'' + 105 + '\',\'' + d.createUsername + '\')">' + d.num3 + '</span>';
                        }
                    },
                    {
                        field: 'num4', title: '其他数', align: 'center', width: '15%', sort: true, templet: function (d) {
                            return '<span class="cursor" style="color: blue;" onclick="showDetailChange(\'' + d.id + '\',\'' + 102 + '\',\'' + d.createUsername + '\')">' + d.num4 + '</span>';
                        }
                    },
                    {
                        field: 'num', title: '总数', align: 'center', width: '15%', sort: true, templet: function (d) {
                            return '<span class="cursor" style="color: blue;" onclick="showDetailChange(\'' + d.id + '\',\'' + 1111 + '\',\'' + d.createUsername + '\')">' + d.num + '</span>';
                        }
                    }
                ]],
                done: function (res, currentCount) {
                    //***重点***：table渲染完成后渲染element进度条
                    element.render();
                    $(".layui-table-page select").css("width", "80px");

                }
            });

        });

    }

    //文档列表
    function showDetailChange(id, types, name) {
        var type = "auto";
        var w = "70%";
        var h = "90%";
        console.log("id:" + id + ",type:" + types);
        url = "/search/decision/bastPracticeFile?id=" + id + "&types=" + types + "&name=" + name + "&deptName=" + name;
        layer.open({
            id: 'form-add',
            type: 2,
            area: [w, h],
            fix: false,
            maxmin: true,
            shadeClose: false,
            shade: 0.4,
            title: "文档列表",
            content: url,
            end: function () {

            }
        });
    }

    function getTableZf() {
        layui.use('table', function () {
            table = layui.table;
            element = element;
            //方法级渲染
            tableIns = table.render({
                id: 'tableList',
                elem: '#tableList',
                url: '/search/decision/showFileByDeptZj',
                height: "auto",
                page: false,
                cols: [[
                    {
                        title: '序号', width: '10%', align: 'center', templet: function (res) {
                            return res.LAY_INDEX;
                        }
                    },
                    {
                        field: 'id', title: 'id', align: 'center', width: '15%', sort: true, hide: true
                    },
                    {
                        field: 'deptName', title: '部门', align: 'center', width: '15%', sort: true
                    },
                    {
                        field: 'num1',
                        title: '案例总结数',
                        align: 'center',
                        width: '15%',
                        sort: true,
                        templet: function (d) {
                            return '<span class="cursor" style="color: blue;" onclick="showDetailDep(\'' + d.id + '\',\'' + 103 + '\',\'' + d.deptName + '\')">' + d.num1 + '</span>';
                        }
                    },
                    {
                        field: 'num2',
                        title: '行业总结数',
                        align: 'center',
                        width: '15%',
                        sort: true,
                        templet: function (d) {
                            return '<span class="cursor" style="color: blue;" onclick="showDetailDep(\'' + d.id + '\',\'' + 104 + '\',\'' + d.deptName + '\')">' + d.num2 + '</span>';
                        }
                    },
                    {
                        field: 'num3',
                        title: '束后总结数',
                        align: 'center',
                        width: '15%',
                        sort: true,
                        templet: function (d) {
                            return '<span class="cursor" style="color: blue;" onclick="showDetailDep(\'' + d.id + '\',\'' + 105 + '\',\'' + d.deptName + '\')">' + d.num3 + '</span>';
                        }
                    },
                    {
                        field: 'num4', title: '其他数', align: 'center', width: '15%', sort: true, templet: function (d) {
                            return '<span class="cursor" style="color: blue;" onclick="showDetailDep(\'' + d.id + '\',\'' + 102 + '\',\'' + d.deptName + '\')">' + d.num4 + '</span>';
                        }
                    },
                    {
                        field: 'num', title: '总数', align: 'center', width: '15%', sort: true, templet: function (d) {
                            return '<span class="cursor" style="color: blue;" onclick="showDetailDep(\'' + d.id + '\',\'' + 1111 + '\',\'' + d.deptName + '\')">' + d.num + '</span>';
                        }
                    }
                ]],
                done: function (res, currentCount) {
                    //***重点***：table渲染完成后渲染element进度条
                    element.render();
                    $(".layui-table-page select").css("width", "80px");

                }
            });

        });

    }

    //文档列表
    function showDetailDep(id, types, deptName) {
        var type = "auto";
        var w = "70%";
        var h = "90%";
        console.log("id:" + id + ",type:" + types);
        url = "/search/decision/bastPracticeFile?deptCode=" + id + "&types=" + types + "&deptName=" + deptName;
        layer.open({
            id: 'form-add',
            type: 2,
            area: [w, h],
            fix: false,
            maxmin: true,
            shadeClose: false,
            shade: 0.4,
            title: "文档列表",
            content: url,
            end: function () {

            }
        });
    }

    function userCertDetail(id) {
        var title = "";
        var w = "";
        var h = "";
        if (w == null || w == '') {
            w = ($(window).width() - 200);
        }
        ;
        if (h == null || h == '') {
            h = ($(window).height() - 50);
        }
        var certName = certName;
        var url = "/search/personTj/certTjDetail?id=" + id;
        parent.layer.open({
            id: 'form-list',
            type: 2,
            area: [w + 'px', h + 'px'],
            fix: false,
            maxmin: true,
            shadeClose: false,
            shade: 0.4,
            title: title,
            content: url,
            success: function (layero) {
                layero.find('.layui-layer-min').remove();
            }
        });


    }


    function dobestDetail(dobest) {
        var title = "";
        var w = "";
        var h = "";
        if (w == null || w == '') {
            w = ($(window).width() - 200);
        }
        ;
        if (h == null || h == '') {
            h = ($(window).height() - 50);
        }
        var doBest = dobest;
        var url = "/search/personTj/doBestTjDetail?doBest=" + doBest;
        parent.layer.open({
            id: 'form-list',
            type: 2,
            area: [w + 'px', h + 'px'],
            fix: false,
            maxmin: true,
            shadeClose: false,
            shade: 0.4,
            title: title,
            content: url,
            success: function (layero) {
                layero.find('.layui-layer-min').remove();
            }
        });


    }

    function zsDetail(certName) {
        var title = "";
        var w = "";
        var h = "";
        if (w == null || w == '') {
            w = ($(window).width() - 200);
        }
        ;
        if (h == null || h == '') {
            h = ($(window).height() - 50);
        }
        var certName = certName;
        var url = "/search/personTj/certTjDetail?certName=" + certName;
        parent.layer.open({
            id: 'form-list',
            type: 2,
            area: [w + 'px', h + 'px'],
            fix: false,
            maxmin: true,
            shadeClose: false,
            shade: 0.4,
            title: title,
            content: url,
            success: function (layero) {
                layero.find('.layui-layer-min').remove();
            }
        });


    }


    function provinceChange(object) {
        var code = $(object).find('option:selected').val();
        if (code == "") {
            return;
        }
        layerAjaxGet('/sys/register/getOrganize', {"code": code}, '', function (d) {
            if (d.flag == true) {
                $(object).next().empty().append("<option value=''>选择市</option>");
                for (var i = 0; i < d.data.length; i++) {
                    $("#city").append("<option value='" + d.data[i].code + "'>" + d.data[i].name + "</option>");
                }
            } else {
                layer.msg(d.msg, {icon: 2});
            }
        });


    };


    //导出
    function exportTable() {
        var data = $(".layui-this").val();
        var createUsername;
        if (data == 2) {
            createUsername = $('#createUsername').val();
        }
        var url = '/search/decision/exportTable?types=' + data + '&createUsername=' + createUsername;
        location.href = url;

    }

    //预览excel
    function viewTable() {
        var data = $(".layui-this").val();
        var createUsername;
        if (data == 2) {
            createUsername = $('#createUsername').val();
        }
        layerAjaxGet('/search/decision/viewTable?types=' + data + '&createUsername=' + createUsername, '', '', function (res) {
            if (res.flag) {
                if (res.data) {
                    var w = ($(window).width() * 0.8);
                    var h = ($(window).height() * 0.8);
                    POBrowser.openWindowModeless('/sys/office/openwordTemp?ft=1&fid=' + res.data, 'width=1200px;height=800px;', '{}')
                }
            }
        })
    }

    $(function () {
        //回车事件
        $(document).keydown(function (e) {
            // 兼容FF和IE和Opera
            var theEvent = e || window.event;
            var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
            if (code == 13) {
                query(2);
            }
            return true;
        });
    })
</script>
</body>

</html>
